import 'package:fate_blind_box/config/app_style.dart';
import 'package:fate_blind_box/theme/theme_color.dart';
import 'package:fate_blind_box/widget/appbar.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import 'logic.dart';

class SalesLevelPage extends GetView<SalesLevelLogic> {
  const SalesLevelPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: HzAppBar(
        text: '销售级别',
        backgroundColor: 'F9F9F9'.stringToColor,
      ),
      backgroundColor: 'F9F9F9'.stringToColor,
      body: Column(
        children: [
          _buildItem('普通', src: 'images/Lv_1.png', isSelected: false),
          _buildItem('销售商', src: 'images/Lv_2.png'),
          _buildItem('销售总监', src: 'images/Lv_3.png'),
          _buildItem('大区总监', src: 'images/Lv_4.png'),
        ],
      ),
    );
  }

  /// 构建item
  Widget _buildItem(String title, {String? src, bool isSelected = true}) {
    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
      margin: const EdgeInsets.symmetric(vertical: 7, horizontal: 14),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(4.w),
      ),
      child: Row(
        children: [
          Image.asset(
            src ?? 'images/Lv_1.png',
            width: 49.w,
            height: 49.w,
          ),
          SizedBox(width: 10.w),
          Expanded(
            child: Text(
              title,
              style: TextStyle(
                fontSize: 16,
                color: '#191919'.stringToColor,
              ),
            ),
          ),
          Visibility(
            visible: isSelected,
            child: Container(
              alignment: Alignment.center,
              width: 56.w,
              height: 28.w,
              decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(28),
                  color: ThemeColor.appColor),
              child: Text(
                '申请',
                style: TextStyle(
                  fontSize: 14.sp,
                  color: Colors.white,
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
